home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Entwickler / Mac-OS / oxygen / samples / docbook / xsl / html / sections.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-09  |  13.1 KB  |  352 lines  |  [□□□□/□□□□]

  1. sections.xsl2Fπ¢tÚπ¢tÚÅÅΩ∑<?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 version='1.0'>
  4.  
  5. <!-- ********************************************************************
  6.      $Id: sections.xsl,v 1.1 2002/05/29 09:55:49 dan Exp $
  7.      ********************************************************************
  8.  
  9.      This file is part of the XSL DocBook Stylesheet distribution.
  10.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  11.      and other information.
  12.  
  13.      ******************************************************************** -->
  14.  
  15. <!-- ==================================================================== -->
  16.  
  17. <xsl:template match="section">
  18.   <xsl:variable name="depth" select="count(ancestor::section)+1"/>
  19.  
  20.   <div class="{name(.)}">
  21.     <xsl:call-template name="section.titlepage"/>
  22.  
  23.     <xsl:variable name="toc.params">
  24.       <xsl:call-template name="find.path.params">
  25.         <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  26.       </xsl:call-template>
  27.     </xsl:variable>
  28.  
  29.     <xsl:if test="(contains($toc.params, 'toc')
  30.                    and $depth <= $generate.section.toc.level)
  31.                   or refentry">
  32.       <xsl:call-template name="section.toc"/>
  33.     </xsl:if>
  34.     <xsl:apply-templates/>
  35.     <xsl:call-template name="process.chunk.footnotes"/>
  36.   </div>
  37. </xsl:template>
  38.  
  39. <xsl:template name="section.title">
  40.   <!-- the context node should be the title of a section when called -->
  41.   <xsl:variable name="section" select="(ancestor::section
  42.                                         |ancestor::simplesect
  43.                                         |ancestor::sect1
  44.                                         |ancestor::sect2
  45.                                         |ancestor::sect3
  46.                                         |ancestor::sect4
  47.                                         |ancestor::sect5)[last()]"/>
  48.  
  49.   <xsl:variable name="level">
  50.     <xsl:call-template name="section.level">
  51.       <xsl:with-param name="node" select="$section"/>
  52.     </xsl:call-template>
  53.   </xsl:variable>
  54.  
  55.   <xsl:call-template name="section.heading">
  56.     <xsl:with-param name="section" select=".."/>
  57.     <xsl:with-param name="level" select="$level"/>
  58.     <xsl:with-param name="title">
  59.       <xsl:apply-templates select="$section" mode="object.title.markup">
  60.         <xsl:with-param name="allow-anchors" select="1"/>
  61.       </xsl:apply-templates>
  62.     </xsl:with-param>
  63.   </xsl:call-template>
  64. </xsl:template>
  65.  
  66. <xsl:template match="section/title" mode="titlepage.mode" priority="2">
  67.   <xsl:call-template name="section.title"/>
  68. </xsl:template>
  69.  
  70. <xsl:template match="sect1">
  71.   <div class="{name(.)}">
  72.     <xsl:call-template name="sect1.titlepage"/>
  73.  
  74.     <xsl:variable name="toc.params">
  75.       <xsl:call-template name="find.path.params">
  76.         <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  77.       </xsl:call-template>
  78.     </xsl:variable>
  79.  
  80.     <xsl:if test="(contains($toc.params, 'toc')
  81.                    and $generate.section.toc.level >= 1)
  82.                   or refentry">
  83.       <xsl:call-template name="section.toc"/>
  84.     </xsl:if>
  85.     <xsl:apply-templates/>
  86.     <xsl:call-template name="process.chunk.footnotes"/>
  87.   </div>
  88. </xsl:template>
  89.  
  90. <xsl:template match="sect1/title" mode="titlepage.mode" priority="2">
  91.   <xsl:call-template name="section.title"/>
  92. </xsl:template>
  93.  
  94. <xsl:template match="sect2">
  95.   <div class="{name(.)}">
  96.     <xsl:call-template name="sect2.titlepage"/>
  97.  
  98.     <xsl:variable name="toc.params">
  99.       <xsl:call-template name="find.path.params">
  100.         <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  101.       </xsl:call-template>
  102.     </xsl:variable>
  103.  
  104.     <xsl:if test="(contains($toc.params, 'toc')
  105.                    and $generate.section.toc.level >= 2)
  106.                   or refentry">
  107.       <xsl:call-template name="section.toc"/>
  108.     </xsl:if>
  109.     <xsl:apply-templates/>
  110.   </div>
  111. </xsl:template>
  112.  
  113. <xsl:template match="sect2/title" mode="titlepage.mode" priority="2">
  114.   <xsl:call-template name="section.title"/>
  115. </xsl:template>
  116.  
  117. <xsl:template match="sect3">
  118.   <div class="{name(.)}">
  119.     <xsl:call-template name="sect3.titlepage"/>
  120.  
  121.     <xsl:variable name="toc.params">
  122.       <xsl:call-template name="find.path.params">
  123.         <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  124.       </xsl:call-template>
  125.     </xsl:variable>
  126.  
  127.     <xsl:if test="(contains($toc.params, 'toc')
  128.                    and $generate.section.toc.level >= 3)
  129.                   or refentry">
  130.       <xsl:call-template name="section.toc"/>
  131.     </xsl:if>
  132.     <xsl:apply-templates/>
  133.   </div>
  134. </xsl:template>
  135.  
  136. <xsl:template match="sect3/title" mode="titlepage.mode" priority="2">
  137.   <xsl:call-template name="section.title"/>
  138. </xsl:template>
  139.  
  140. <xsl:template match="sect4">
  141.   <div class="{name(.)}">
  142.     <xsl:call-template name="sect4.titlepage"/>
  143.  
  144.     <xsl:variable name="toc.params">
  145.       <xsl:call-template name="find.path.params">
  146.         <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  147.       </xsl:call-template>
  148.     </xsl:variable>
  149.  
  150.     <xsl:if test="(contains($toc.params, 'toc')
  151.                    and $generate.section.toc.level >= 4)
  152.                   or refentry">
  153.       <xsl:call-template name="section.toc"/>
  154.     </xsl:if>
  155.     <xsl:apply-templates/>
  156.   </div>
  157. </xsl:template>
  158.  
  159. <xsl:template match="sect4/title" mode="titlepage.mode" priority="2">
  160.   <xsl:call-template name="section.title"/>
  161. </xsl:template>
  162.  
  163. <xsl:template match="sect5">
  164.   <div class="{name(.)}">
  165.     <xsl:call-template name="sect5.titlepage"/>
  166.  
  167.     <xsl:variable name="toc.params">
  168.       <xsl:call-template name="find.path.params">
  169.         <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  170.       </xsl:call-template>
  171.     </xsl:variable>
  172.  
  173.     <xsl:if test="(contains($toc.params, 'toc')
  174.                    and $generate.section.toc.level >= 5)
  175.                   or refentry">
  176.       <xsl:call-template name="section.toc"/>
  177.     </xsl:if>
  178.     <xsl:apply-templates/>
  179.   </div>
  180. </xsl:template>
  181.  
  182. <xsl:template match="sect5/title" mode="titlepage.mode" priority="2">
  183.   <xsl:call-template name="section.title"/>
  184. </xsl:template>
  185.  
  186. <xsl:template match="simplesect">
  187.   <div class="{name(.)}">
  188.     <xsl:call-template name="simplesect.titlepage"/>
  189.     <xsl:apply-templates/>
  190.   </div>
  191. </xsl:template>
  192.  
  193. <xsl:template match="simplesect/title" mode="titlepage.mode" priority="2">
  194.   <xsl:call-template name="section.title"/>
  195. </xsl:template>
  196.  
  197. <xsl:template match="section/title"></xsl:template>
  198. <xsl:template match="section/titleabbrev"></xsl:template>
  199. <xsl:template match="section/subtitle"></xsl:template>
  200. <xsl:template match="sectioninfo"></xsl:template>
  201.  
  202. <xsl:template match="sect1/title"></xsl:template>
  203. <xsl:template match="sect1/titleabbrev"></xsl:template>
  204. <xsl:template match="sect1/subtitle"></xsl:template>
  205. <xsl:template match="sect1info"></xsl:template>
  206.  
  207. <xsl:template match="sect2/title"></xsl:template>
  208. <xsl:template match="sect2/subtitle"></xsl:template>
  209. <xsl:template match="sect2/titleabbrev"></xsl:template>
  210. <xsl:template match="sect2info"></xsl:template>
  211.  
  212. <xsl:template match="sect3/title"></xsl:template>
  213. <xsl:template match="sect3/subtitle"></xsl:template>
  214. <xsl:template match="sect3/subtitle"></xsl:template>
  215. <xsl:template match="sect3info"></xsl:template>
  216.  
  217. <xsl:template match="sect4/title"></xsl:template>
  218. <xsl:template match="sect4/subtitle"></xsl:template>
  219. <xsl:template match="sect4/subtitle"></xsl:template>
  220. <xsl:template match="sect4info"></xsl:template>
  221.  
  222. <xsl:template match="sect5/title"></xsl:template>
  223. <xsl:template match="sect5/subtitle"></xsl:template>
  224. <xsl:template match="sect5/subtitle"></xsl:template>
  225. <xsl:template match="sect5info"></xsl:template>
  226.  
  227. <xsl:template match="simplesect/title"></xsl:template>
  228. <xsl:template match="simplesect/titleabbrev"></xsl:template>
  229. <xsl:template match="simplesect/subtitle"></xsl:template>
  230.  
  231. <!-- ==================================================================== -->
  232.  
  233. <xsl:template name="section.heading">
  234.   <xsl:param name="section" select="."/>
  235.   <xsl:param name="level" select="'1'"/>
  236.   <xsl:param name="title"/>
  237.  
  238.   <xsl:variable name="id">
  239.     <xsl:choose>
  240.       <!-- if title is in an *info wrapper, get the grandparent -->
  241.       <xsl:when test="contains(local-name(..), 'info')">
  242.         <xsl:call-template name="object.id">
  243.           <xsl:with-param name="object" select="../.."/>
  244.         </xsl:call-template>
  245.       </xsl:when>
  246.       <xsl:otherwise>
  247.         <xsl:call-template name="object.id">
  248.           <xsl:with-param name="object" select=".."/>
  249.         </xsl:call-template>
  250.       </xsl:otherwise>
  251.     </xsl:choose>
  252.   </xsl:variable>
  253.  
  254.   <xsl:element name="h{$level}">
  255.     <xsl:attribute name="class">title</xsl:attribute>
  256.     <xsl:if test="$css.decoration != '0'">
  257.       <xsl:if test="$level<3">
  258.         <xsl:attribute name="style">clear: both</xsl:attribute>
  259.       </xsl:if>
  260.     </xsl:if>
  261.     <xsl:call-template name="anchor">
  262.       <xsl:with-param name="node" select="$section"/>
  263.       <xsl:with-param name="conditional" select="0"/>
  264.     </xsl:call-template>
  265.     <xsl:copy-of select="$title"/>
  266.   </xsl:element>
  267. </xsl:template>
  268.  
  269. <!-- ==================================================================== -->
  270.  
  271. <xsl:template match="bridgehead">
  272.   <xsl:variable name="container"
  273.                 select="(ancestor::appendix
  274.                         |ancestor::article
  275.                         |ancestor::bibliography
  276.                         |ancestor::chapter
  277.                         |ancestor::glossary
  278.                         |ancestor::glossdiv
  279.                         |ancestor::index
  280.                         |ancestor::partintro
  281.                         |ancestor::preface
  282.                         |ancestor::refsect1
  283.                         |ancestor::refsect2
  284.                         |ancestor::refsect3
  285.                         |ancestor::sect1
  286.                         |ancestor::sect2
  287.                         |ancestor::sect3
  288.                         |ancestor::sect4
  289.                         |ancestor::sect5
  290.                         |ancestor::section
  291.                         |ancestor::setindex
  292.                         |ancestor::simplesect)[last()]"/>
  293.  
  294.   <xsl:variable name="clevel">
  295.     <xsl:choose>
  296.       <xsl:when test="local-name($container) = 'appendix'
  297.                       or local-name($container) = 'chapter'
  298.                       or local-name($container) = 'article'
  299.                       or local-name($container) = 'bibliography'
  300.                       or local-name($container) = 'glossary'
  301.                       or local-name($container) = 'index'
  302.                       or local-name($container) = 'partintro'
  303.                       or local-name($container) = 'preface'
  304.                       or local-name($container) = 'setindex'">2</xsl:when>
  305.       <xsl:when test="local-name($container) = 'glossdiv'">
  306.         <xsl:value-of select="count(ancestor::glossdiv)+2"/>
  307.       </xsl:when>
  308.       <xsl:when test="local-name($container) = 'sect1'
  309.                       or local-name($container) = 'sect2'
  310.                       or local-name($container) = 'sect3'
  311.                       or local-name($container) = 'sect4'
  312.                       or local-name($container) = 'sect5'
  313.                       or local-name($container) = 'refsect1'
  314.                       or local-name($container) = 'refsect2'
  315.                       or local-name($container) = 'refsect3'
  316.                       or local-name($container) = 'section'
  317.                       or local-name($container) = 'simplesect'">
  318.         <xsl:variable name="slevel">
  319.           <xsl:call-template name="section.level">
  320.             <xsl:with-param name="node" select="$container"/>
  321.           </xsl:call-template>
  322.         </xsl:variable>
  323.         <xsl:value-of select="$slevel + 1"/>
  324.       </xsl:when>
  325.       <xsl:otherwise>2</xsl:otherwise>
  326.     </xsl:choose>
  327.   </xsl:variable>
  328.  
  329.   <xsl:variable name="level">
  330.     <xsl:choose>
  331.       <xsl:when test="@renderas = 'sect1'">2</xsl:when>
  332.       <xsl:when test="@renderas = 'sect2'">3</xsl:when>
  333.       <xsl:when test="@renderas = 'sect3'">4</xsl:when>
  334.       <xsl:when test="@renderas = 'sect4'">5</xsl:when>
  335.       <xsl:when test="@renderas = 'sect5'">6</xsl:when>
  336.       <xsl:otherwise>
  337.         <xsl:value-of select="$clevel"/>
  338.       </xsl:otherwise>
  339.     </xsl:choose>
  340.   </xsl:variable>
  341.  
  342.   <xsl:element name="h{$level}">
  343.     <xsl:call-template name="anchor">
  344.       <xsl:with-param name="conditional" select="0"/>
  345.     </xsl:call-template>
  346.     <xsl:apply-templates/>
  347.   </xsl:element>
  348. </xsl:template>
  349.  
  350. </xsl:stylesheet>
  351.  
  352. This resource fork intentionally left blank   ˇˇ